import { AxiosInstance } from "axios";
import {
    PartitionType,
    createPartitionTypes
} from "@/models";
import {
    URL_PARTITIONS,
    URL_RANKING_PARTITIONS,
    URL_RANKING,
} from './url'
import { axiosInstance } from "./config";

// export const getPartitionsRequest = (): Promise<PartitionType[]> => {
//     const promise = new Promise<PartitionType[]>((resolve,reject) => {
//         try {
//             axiosInstance.get(URL_PARTITIONS).then(
//                 response => resolve(mapPartitionListToModel(response))
//             )
//         } catch(e){
//             reject(e)
//         }
//     })
//     return promise;
// }

// const mapPartitionListToModel = ({ data } : any): PartitionType[] => {
//     const partitions = data["0"];
//     let oneLevels = createPartitionTypes(partitions);
//     oneLevels = oneLevels.filter((partition) =>
//         [13, 23, 11, 177].indexOf(partition.id) === -1);
//     return oneLevels;
// }

export const getPartitionsRequest = () =>
    axiosInstance.get(URL_PARTITIONS)

export const getRankingPartitionsRequest = () =>
    axiosInstance.get(URL_RANKING_PARTITIONS)

export const getRankingRequest = (rId: string) => {
    let url = `${URL_RANKING}/${rId}`
    return axiosInstance.get(url)
}